package cn.iocoder.yudao.module.jifenyuan.dal.mysql.roomlog;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.jifenyuan.dal.dataobject.roomlog.RoomLogDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.jifenyuan.controller.app.roomlog.vo.*;

/**
 * 记分员 房间记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface RoomLogMapper extends BaseMapperX<RoomLogDO> {

    default PageResult<RoomLogDO> selectPage(AppRoomLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RoomLogDO>()
                .eqIfPresent(RoomLogDO::getRoomId, reqVO.getRoomId())
                .eqIfPresent(RoomLogDO::getFromUser, reqVO.getFromUser())
                .eqIfPresent(RoomLogDO::getToUser, reqVO.getToUser())
                .eqIfPresent(RoomLogDO::getScore, reqVO.getScore())
                .betweenIfPresent(RoomLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RoomLogDO::getId));
    }

    default List<RoomLogDO> selectList(AppRoomLogExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<RoomLogDO>()
                .eqIfPresent(RoomLogDO::getRoomId, reqVO.getRoomId())
                .eqIfPresent(RoomLogDO::getFromUser, reqVO.getFromUser())
                .eqIfPresent(RoomLogDO::getToUser, reqVO.getToUser())
                .eqIfPresent(RoomLogDO::getScore, reqVO.getScore())
                .betweenIfPresent(RoomLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RoomLogDO::getId));
    }

   default List<RoomLogDO> getRoomLogByRoomId(Long roomId){
        return selectList(new LambdaQueryWrapperX<RoomLogDO>().eqIfPresent(RoomLogDO::getRoomId, roomId).orderByDesc(RoomLogDO::getCreateTime));
   }

}
